package com.woniu.microcommunityserver.book.service.impl;

import com.woniu.microcommunityserver.book.entity.BorrowRevertInformationInfoEntity;
import com.woniu.microcommunityserver.book.mapper.BookInformationInfoMapper;
import com.woniu.microcommunityserver.book.mapper.BorrowRevertInformationInfoMapper;
import com.woniu.microcommunityserver.book.service.BorrowRevertInformationInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class BorrowRevertInformationInfoServiceImpl implements BorrowRevertInformationInfoService {
    @Resource
    private BorrowRevertInformationInfoMapper borrowRevertInformationInfoMapper;
    @Resource
    private BookInformationInfoMapper bookInformationInfoMapper;

    @Override
    public List<BorrowRevertInformationInfoEntity> findAll() {
        return borrowRevertInformationInfoMapper.findAll();
    }

    @Override
    public List<BorrowRevertInformationInfoEntity> findAny(Map<String, Object> map) {
        return borrowRevertInformationInfoMapper.findAny(map);
    }

    @Override
    public boolean insertBorrow(BorrowRevertInformationInfoEntity borrowRevertInformationInfoEntity) {
        boolean flag = borrowRevertInformationInfoMapper.insertBorrow(borrowRevertInformationInfoEntity);
        boolean flag1 =bookInformationInfoMapper.loanBook(borrowRevertInformationInfoEntity.getFkBookId());
        if (flag && flag1){
            return true;
        }else
        return false;
    }

    @Override
    public boolean updateState(Long id,String revertTime) {
        return borrowRevertInformationInfoMapper.updateState(id,revertTime);
    }

}
